import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import org.w3c.dom.ls.LSOutput;

import java.util.*;

/**
 * @author ：FeatherWaves
 * @description：TODO
 * @date ：2021/8/18 12:08
 */
class MyException extends Exception{
    public MyException() {
        super();
    }

    public MyException(String message) {
        super(message);
    }
}
public class Test {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("及时雨", "宋江");
        map.put("黑旋风", "李逵");
        System.out.println(map);
        String s = map.getOrDefault("黑旋风1", "ok");
        System.out.println(s);
        System.out.println(map.containsKey("及时雨"));
        Set<Map.Entry<String, String>> set = map.entrySet();
        for (Map.Entry<String, String> entry : set) {
            System.out.println(entry.getKey() + "->>" + entry.getValue());
        }
    }
    public static void main4(String[] args) {
        Collection<String> cn = new ArrayList<>();
        cn.add("nihao");
        cn.add("ok");
        Object[] ot = cn.toArray();
        System.out.println(cn);
        for (String s : cn) {
            System.out.println(s);
        }
        System.out.println(Arrays.toString(ot));
        System.out.println(cn.size());
        System.out.println(cn.isEmpty());
        cn.remove("ok");
        System.out.println(cn.size());
        cn.clear();
        System.out.println(cn.isEmpty());

    }
    public static void Me(int a) throws MyException {
        if (a == 0) {
            throw new MyException("a == 10");
        }
    }
    public static void main3(String[] args) {
        try {
            Me(0);
        } catch (MyException e) {
            e.printStackTrace();
        }
        int[] arr = {1,2,3};
        try {
            System.out.println(arr[4]);
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
            System.out.println("数组越界");
        }
    }
    public static void main2(String[] args) throws CloneNotSupportedException {
        Person p1 = new Person();
        Person p2 = (Person)p1.clone();
        System.out.println(p1.mo.b);
        System.out.println(p2.mo.b);
        System.out.println("========修改后=========");
        p1.mo.b = 1;
        System.out.println(p1.mo.b);
        System.out.println(p2.mo.b);
    }
    public static void main1(String[] args) {
        Star st = new Star();
        Circle ce = new Circle();
        Print(st);
        Print(ce);
        Shape[] input = {new Circle(), new Star(), new Circle()};
        for (Shape in : input) {
            in.draw();
        }
    }
    public static void Print(Shape se) {
        se.draw();
    }
}
class Money implements Cloneable {
    public int b;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Person implements Cloneable{
    public int a;
    public Money mo = new Money();
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person p = (Person)super.clone();
        p.mo = (Money)this.mo.clone();
        return p;
    }
}
class Shape {

    public void draw() {

    }
}

class Circle extends Shape {
    @Override
    public void draw() {
        System.out.println("⚪");
    }
}

class Star extends Shape {
    @Override
    public void draw() {
        System.out.println("⭐");
    }
}

